package com.hx.reflect;

import com.hx.reflect.bean.Student;

import java.lang.reflect.Field;

/**
 * @author MinghuaChen
 * @date 2022-04-30 00:22
 * @description
 */
public class Main8 {

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        Class<Student> clazz = Student.class;

        Field name = clazz.getDeclaredField("name");

        Student student =new Student();
        student.setName("lucy");

        String realName =(String) name.get(student);

        System.out.println(realName);

    }

}
